#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
时间：2023/12/5 20:50
作者：南城九叔
"""
import os
import sys
import time

from PySide6.QtCore import *
from PySide6.QtGui import *
from PySide6.QtGui import QPixmap
from PySide6.QtNetwork import QNetworkAccessManager, QNetworkRequest
from PySide6.QtWidgets import *

from config import USERS

appIcon = b'<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1701781033447" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5302" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M607.9 289.2s105.6-135.5 171.4-130.8c65.7 4.8 24.8 276 0 278.5" fill="#F4B35D" p-id="5303"></path><path d="M779.8 441.9l-1-9.9c-0.2 0-0.3 0.1-0.3 0.1s4.8-2.4 11.7-25.5c4.7-15.8 9.2-37.1 12.6-60.1 8-53.6 9.2-105.7 3.2-139.6-3.4-19.2-10.9-42.2-27.1-43.4-62.3-4.5-166 127.5-167.1 128.8l-7.9-6.1c4.4-5.6 108.1-137.6 175.7-132.7 25.4 1.8 39.2 35.8 40.1 98.1 0.5 37.3-3.8 83.4-11.7 123.2-3.6 18.5-7.8 34.2-12 45.6-5.1 14.3-10.2 20.9-16.2 21.5z" fill="" p-id="5304"></path><path d="M642.4 303.3s62.7-80.6 103.5-77.6 21.6 166.3 6.2 167.9" fill="#FFFFFF" p-id="5305"></path><path d="M416.6 289.2S311 153.7 245.2 158.4c-65.7 4.8-24.8 276 0 278.5" fill="#F4B35D" p-id="5306"></path><path d="M244.7 441.9c-6-0.6-11-7.3-16.3-21.5-4.2-11.3-8.3-27.1-12-45.6-7.9-39.9-12.2-85.9-11.7-123.2 0.9-62.4 14.8-96.3 40.1-98.1 67.6-4.9 171.3 127 175.7 132.7l-7.9 6.1c-1-1.3-104.7-133.3-167.1-128.8-16.2 1.2-23.7 24.3-27.1 43.4-6 33.8-4.8 86 3.2 139.6 3.4 23 7.9 44.3 12.6 60.1 7.1 23 11.8 25.4 11.8 25.4s-0.1 0-0.3-0.1l-1 10z" fill="" p-id="5307"></path><path d="M382.1 303.3s-62.7-80.6-103.5-77.6S257 392 272.4 393.6" fill="#FFFFFF" p-id="5308"></path><path d="M512.2 573.6m-300 0a300 300 0 1 0 600 0 300 300 0 1 0-600 0Z" fill="#F4B35D" p-id="5309"></path><path d="M512.2 878.6c-81.5 0-158.1-31.7-215.7-89.3-57.6-57.6-89.3-134.2-89.3-215.7s31.7-158.1 89.3-215.7c57.6-57.6 134.2-89.3 215.7-89.3s158.1 31.7 215.7 89.3c57.6 57.6 89.3 134.2 89.3 215.7s-31.7 158.1-89.3 215.7c-57.7 57.6-134.3 89.3-215.7 89.3z m0-600c-162.7 0-295 132.3-295 295s132.3 295 295 295 295-132.3 295-295-132.4-295-295-295z" fill="" p-id="5310"></path><path d="M383.500692 449.890758a33.7 24 29.53 1 0 58.644588 33.220058 33.7 24 29.53 1 0-58.644588-33.220058Z" fill="#FFFFFF" p-id="5311"></path><path d="M637.306781 449.967703a24 33.7 60.47 1 0-58.644588 33.220059 24 33.7 60.47 1 0 58.644588-33.220059Z" fill="#FFFFFF" p-id="5312"></path><path d="M811.6 591c-9 157.5-139.6 282.5-299.4 282.5-159.6 0-290.1-124.7-299.5-282 0 0 119.7-37.3 220.1-1.3 0 0 78.8-37.7 158.6 0 0 0.1 68-36.3 220.2 0.8z" fill="#FFFFFF" p-id="5313"></path><path d="M512.2 876c-159.9 0-292.5-124.9-302-284.3l-0.1-2 1.9-0.6c0.3-0.1 30.6-9.4 72.9-14.2 38.8-4.4 95.8-5.7 147.9 12.6 4.3-2 22.7-9.7 49.1-13.9 27.2-4.3 68.1-5.4 109.6 13.8 4.4-2.1 21.5-9.4 52.8-13.3 33.1-4.1 89.1-4.9 168.1 14.3l2 0.5-0.1 2.1c-9.3 159.9-142 285-302.1 285zM215.3 593.4C225.6 749.2 355.6 871 512.2 871 669 871 799 749 809 592.9c-77-18.5-131.6-17.7-163.9-13.8-35.3 4.3-52.4 13.2-52.6 13.3l-1.1 0.6-1.1-0.5c-40.6-19.2-80.9-18.2-107.6-14-29 4.6-48.7 13.9-48.8 14l-0.9 0.4-1-0.4c-51.4-18.4-108-17.1-146.5-12.7-35.9 4.1-63 11.5-70.2 13.6z" fill="" p-id="5314"></path><path d="M504.9 579.8l7.4 6.4c1.8 1.5 6.1 1.5 7.9 0l7.4-6.4c1.8-1.5-0.4-3.4-3.9-3.4H509c-3.6 0-5.8 1.9-4.1 3.4z" fill="" p-id="5315"></path><path d="M516.3 588.9c-1.9 0-3.8-0.5-4.9-1.5L504 581c-1-0.9-1.4-2.1-1-3.2 0.6-1.7 3-2.8 5.9-2.8h14.7c2.9 0 5.3 1.1 5.9 2.8 0.4 1.1 0.1 2.3-1 3.2l-7.4 6.4c-1.1 1-3 1.5-4.8 1.5z m-10.4-10.2l7.4 6.4c1.2 1 4.7 1 5.9 0l7.4-6.4c-0.3-0.3-1.3-0.8-3-0.8h-14.7c-1.7 0-2.7 0.5-3 0.8z" fill="" p-id="5316"></path><path d="M475.2 634.4c-7 0-13.4-1.2-18.2-3.5-8.7-4.3-11.4-12.1-7.1-20.8l4.5 2.2c-3.1 6.3-1.4 11.1 4.8 14.1 13.8 6.8 44.4 2.6 52.6-14 1-2 2.9-3.3 5.3-3.4 2.3-0.1 4.4 0.8 5.3 2.3 8.8 14.2 37.1 18 50.9 10.3 6.3-3.5 7.9-8.5 4.8-14.8l4.5-2.2c4.3 8.8 1.8 16.6-6.9 21.4-7.5 4.1-19.1 5.5-30.4 3.6-12.3-2.1-22.2-7.7-27.1-15.5-0.2-0.1-0.8-0.2-1.3-0.1-0.4 0.1-0.6 0.3-0.7 0.5-6.6 13.6-25.1 19.9-41 19.9z" fill="" p-id="5317"></path><path d="M260.4 632.6a57.5 21.3 0 1 0 115 0 57.5 21.3 0 1 0-115 0Z" fill="#FFD4DC" p-id="5318"></path><path d="M648.9 631.2a57.5 21.3 0 1 0 115 0 57.5 21.3 0 1 0-115 0Z" fill="#FFD4DC" p-id="5319"></path><path d="M361.2 573.6m-55 0a55 55 0 1 0 110 0 55 55 0 1 0-110 0Z" fill="" p-id="5320"></path><path d="M361.2 630.1c-31.2 0-56.5-25.3-56.5-56.5s25.3-56.5 56.5-56.5 56.5 25.3 56.5 56.5-25.4 56.5-56.5 56.5z m0-110c-29.5 0-53.5 24-53.5 53.5s24 53.5 53.5 53.5 53.5-24 53.5-53.5-24-53.5-53.5-53.5z" fill="" p-id="5321"></path><path d="M337.4 558.4m-15.2 0a15.2 15.2 0 1 0 30.4 0 15.2 15.2 0 1 0-30.4 0Z" fill="#FFFFFF" p-id="5322"></path><path d="M400.3 591.1c2.4 4.2-1.2 14.8-13.9 22.3-12.7 7.5-26.4 6.4-28.9 2.3s9.7-1.6 22.5-9 17.9-19.7 20.3-15.6z" fill="#565656" p-id="5323"></path><path d="M662.9 573.6m-55 0a55 55 0 1 0 110 0 55 55 0 1 0-110 0Z" fill="" p-id="5324"></path><path d="M662.9 630.1c-31.2 0-56.5-25.3-56.5-56.5s25.3-56.5 56.5-56.5 56.5 25.3 56.5 56.5-25.3 56.5-56.5 56.5z m0-110c-29.5 0-53.5 24-53.5 53.5s24 53.5 53.5 53.5 53.5-24 53.5-53.5-24-53.5-53.5-53.5z" fill="" p-id="5325"></path><path d="M639.2 558.4m-15.2 0a15.2 15.2 0 1 0 30.4 0 15.2 15.2 0 1 0-30.4 0Z" fill="#FFFFFF" p-id="5326"></path><path d="M702.1 591.1c2.4 4.2-1.2 14.8-13.9 22.3-12.7 7.5-26.4 6.4-28.9 2.3s9.7-1.6 22.5-9 17.9-19.7 20.3-15.6z" fill="#565656" p-id="5327"></path></svg>'
BASE_DIR = os.path.dirname(os.path.realpath(sys.argv[0]))


def BytesIcon(icon: bytes):
    pixMap = QPixmap()
    pixMap.loadFromData(icon)
    return QIcon(pixMap)


class _Signal(QObject):
    next_kind = Signal(int)
    tip = Signal(str)
    get_applies = False
    stop_auto = Signal()
    stop_apply = True
    get_applying = False
    CS = Signal(QObject)
    products = Signal(dict)
    item = ''
    next_apply = Signal()
    apply_result = Signal(object, object)

    # 用户已申请的商品id字典
    userData = {}
    for user in USERS:
        userData[user] = []


S = _Signal()
